import java.util.Arrays;

public class FrondEvenNumber {
    public static int[] frondEvenNumber(int[] array){
        //挨个检测，如果遇到偶数就把他放到尾端
        //指针思想
        int left = 0;
        int right = array.length-1;
        while(left < right){
            while (left < right && array[left] % 2 != 0){//左端指针为奇数
                left++;//左指针右移
            }
            while (left < right && array[right] % 2 == 0){//右端指针为偶数
                right--;//右指针左移
            }
            int tmp = left;
            tmp = array[left];
            array[left] = array[right];
            array[right] = tmp;
            /*如果是左指针为偶数，右指针为奇数，则把两个指针所指的下标元素交换位置*/
        }
        return array;
    }

    public static void main(String[] args) {
        int array[] = {0,1,2,3,4,5,6,7,8,9};
        System.out.println(Arrays.toString(frondEvenNumber(array)));
    }
}
